package cn.shyouchi.wuguanjia.android.ui.patrol.statistic.page.normal;

import android.app.Activity;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

import cn.bingoogolapple.photopicker.widget.BGASortableNinePhotoLayout;
import cn.shyouchi.wuguanjia.android.Global;
import cn.shyouchi.wuguanjia.android.R;
import cn.shyouchi.wuguanjia.android.ui.patrol.statistic.PatrolStatisticEntity;

/**
 * Created by Eenie on 2016/12/29 at 13:39
 * Email: 472279981@qq.com
 * Des:
 */

public class PatrolStatisticNormalAdapter extends BaseQuickAdapter<PatrolStatisticEntity.ResultMessageBean.InfoBean.InspectionBean, BaseViewHolder> {
    Activity activity;

    public PatrolStatisticNormalAdapter(List<PatrolStatisticEntity.ResultMessageBean.InfoBean.InspectionBean> data, Activity activity) {
        super(R.layout.item_patrol_statistic_normal_layout, data);
        this.activity = activity;
    }

    @Override
    protected void convert(BaseViewHolder holder, PatrolStatisticEntity.ResultMessageBean.InfoBean.InspectionBean entity) {
        holder.setText(R.id.tv_item_position, String.valueOf(holder.getAdapterPosition() + 1));
        holder.setText(R.id.tv_patrol_time, String.format("巡检时间：%1s", entity.getTime()));
        holder.setText(R.id.tv_patrol_state, String.format("巡检状态：%1s", entity.getHappening()));
        holder.setText(R.id.tv_patrol_addr, String.format("巡检地点：%1s", entity.getInspectionname()));

        BGASortableNinePhotoLayout photoLayout = holder.getView(R.id.photo_snpl);
        photoLayout.init(activity);
        photoLayout.setDeleteDrawableResId(R.drawable.photo_del_bg);
        ArrayList<String> imgs = new ArrayList<>();
        for (PatrolStatisticEntity.ResultMessageBean.InfoBean.InspectionBean.ImageBeanX img : entity.getImage()) {
            imgs.add(Global.BASE_URL + img.getImage());
        }
        photoLayout.setData(imgs);
    }
}
